2020-2021 Sunseeker Telemetry and Lighting System
pmap_ex2_outputTimerBSignal.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
65 //******************************************************************************
66 #include "driverlib.h"
67 
68 //*****************************************************************************
69 //
70 //Refer Datasheet for Port4 Port Mapping definitions
71 //
72 //*****************************************************************************
73 const uint8_t port_mapping[] = {
74  //Port P4:
75  PM_TB0CCR1A,
76  PM_TB0CCR1A,
77  PM_TB0CCR2A,
78  PM_TB0CCR2A,
79  PM_TB0CCR3A,
80  PM_TB0CCR3A,
81  PM_NONE,
82  PM_NONE,
83 };
84 
85 void main (void)
86 {
87  //Stop WDT
88  WDT_A_hold(WDT_A_BASE);
89 
90  //Set DCO FLL reference = REFO
91  UCS_initClockSignal(
92  UCS_FLLREF,
93  UCS_REFOCLK_SELECT,
94  UCS_CLOCK_DIVIDER_1
95  );
96 
97  //VLO Clock Sources ACLK
98  UCS_initClockSignal(
99  UCS_ACLK,
100  UCS_REFOCLK_SELECT,
101  UCS_CLOCK_DIVIDER_1
102  );
103 
104  //Set Ratio and Desired MCLK Frequency and initialize DCO
105  UCS_initFLLSettle(
106  1048,
107  32
108  );
109 
110 
111  //Setup Port Pins
112  //P4.0 - P4.7 output
113  //P4.0 - P4.6 Port Map functions
114  GPIO_setAsPeripheralModuleFunctionOutputPin(
115  GPIO_PORT_P4,
116  GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
117  GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
118  GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
119  GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
120  GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
121  GPIO_PIN15
122  );
123 
124  //CONFIGURE PORTS- pass the port_mapping array, start @ P4MAP01, initialize
125  //a single port, do not allow run-time reconfiguration of port mapping
126  PMAP_initPortsParam initPortsParam = {0};
127  initPortsParam.portMapping = port_mapping;
128  initPortsParam.PxMAPy = (uint8_t *)&P4MAP01;
129  initPortsParam.numberOfPorts = 1;
130  initPortsParam.portMapReconfigure = PMAP_DISABLE_RECONFIGURATION;
131  PMAP_initPorts(PMAP_CTRL_BASE, &initPortsParam);
132 
133  //Start Up Down Timer
134  Timer_B_initUpDownModeParam param1 = {0};
135  param1.clockSource = TIMER_B_CLOCKSOURCE_ACLK;
136  param1.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_2;
137  param1.timerPeriod = 128;
138  param1.timerInterruptEnable_TBIE = TIMER_B_TBIE_INTERRUPT_DISABLE;
139  param1.captureCompareInterruptEnable_CCR0_CCIE =
140  TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE;
141  param1.timerClear = TIMER_B_SKIP_CLEAR;
142  param1.startTimer = true;
143  Timer_B_initUpDownMode(TIMER_B0_BASE, &param1);
144 
145  //Generate PWM 1
146  Timer_B_initCompareModeParam param2 = {0};
147  param2.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_1;
148  param2.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
149  param2.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
150  param2.compareValue = 96;
151  Timer_B_initCompareMode(TIMER_B0_BASE, &param2);
152 
153  //Generate PWM 2
154  param2.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_2;
155  param2.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
156  param2.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
157  param2.compareValue = 64;
158  Timer_B_initCompareMode(TIMER_B0_BASE, &param2);
159 
160  //Generate PWM 3
161  param2.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_3;
162  param2.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
163  param2.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
164  param2.compareValue = 32;
165  Timer_B_initCompareMode(TIMER_B0_BASE, &param2);
166 
167  //Enter LPM3
168  __bis_SR_register(LPM3_bits);
169 
170  //For debugger
171  __no_operation();
172 }
173 
__no_operation()
void main(void)
const uint8_t port_mapping[]